﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function Test1() {
            alert("test1");
        };
        // 兼容 事件绑定
        window.onload = function () {
            if (window.attachEvent) {//IE 8及以前
                document.getElementById("btnTest").attachEvent("onclick", Test1);
                document.getElementById("btnTest").attachEvent("onclick", Test2);
            }
            else {//w3c 火狐
                document.getElementById("btnTest").addEventListener("click", Test1, false);
                document.getElementById("btnTest").addEventListener("click", Test2, false);
            }
        };

        function Test2() {
            alert("test2");
        }

    </script>
</head>
<body>
    <input id="btnTest" type="button" value="Test" />
</body>
</html>
